﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.Phone.Controls;
using WP8Demos.Interfaces;

namespace WP8Demos.Services
{
    public class NavigationService : INavigationService
    {
        public NavigationService()
        {
        }

        public void Navigate(Uri pageUri)
        {
            this.PhoneNavigationService.Navigate(pageUri);
        }

        public void Navigate(string pageUri)
        {
            this.PhoneNavigationService.Navigate(new Uri(pageUri, UriKind.Relative));
        }

        private System.Windows.Navigation.NavigationService PhoneNavigationService
        {
            get
            {
                return this.PhoneApplicationPage.NavigationService;
            }
        }

        private PhoneApplicationFrame PhoneApplicationFrame
        {
            get
            {
                return Application.Current.RootVisual as PhoneApplicationFrame;
            }
        }

        private PhoneApplicationPage PhoneApplicationPage
        {
            get
            {
                return this.PhoneApplicationFrame.Content as PhoneApplicationPage;
            }
        }
    }
}
